﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MegavaniaX.Messaging.Events;
using MegavaniaX.World;
using MegavaniaX.Actors.States;
namespace MegavaniaX
{
    /// <summary>
    /// A normal Megaman bullet.
    /// </summary>
    public class Bullet : Actor, IDealsDamage
    {
        private Animation bulletAnim;

        public Bullet(String id)
            : base(id)
        {
            IsAffectedByGravity = false;
            IsAffectedByWalls = false;
            IsRemovable = true;
            IsDealsDamage = true;

            Width = 8;
            Height = 6;

            bulletAnim = AnimationManager.MakeAnimation("bullet");
            StateMachine = new StateMachine(new GenericObjectStateBase(this));
            CurrentAnimation = bulletAnim;
        }

        public override MegavaniaSprite CurrentSprite()
        {
            return CurrentAnimation.CurrentSprite();
        }

        #region IDealsDamage
        public DamageType DamageType { get { return DamageType.Normal; } }

        public int BaseDamage { get { return 1; } }

        public void OnDamageNoDeath()
        {
            // despawn
            MessagingSystem.DispatchEvent(new DespawnActorEvent(MegavaniaEventType.DespawnActor, this));
        }

        public void OnDamageDied()
        {

        }

        private IList<Actor> _damagedActors;
        public IList<Actor> DamagedActors
        {
            get
            {
                if (_damagedActors == null)
                    _damagedActors = new List<Actor>();
                return _damagedActors;
            }
        }

        #endregion

    }
}
